<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>demo2-11</title>
    <script src="./vue.js"></script>
</head>
<body>
    <div id="app">
       姓名：{{ fullName }}
    </div>
</body>
<script>
   const appCom = {
        data(){
            return {
                firstName:"Emily",
                lastName:"Ford"
            }
        },
        computed:{
            fullName:{
                get:function(){
                    console.log('get函数被调用');
                    return this.firstName + " " + this.lastName;
                },
                set:function(newValue){
                    console.log('set函数被调用');
                    var names = newValue.split(' ');
                    this.firstName = names[0];
                    this.lastName = names[1];
                }
            }
        }
    };
    const app = Vue.createApp(appCom).mount('#app')
</script>
</html>